<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>主页 | 米尔豪斯酒店网上订餐</title>
    <link rel="stylesheet" type="text/css" href="../css/zhongcan_order.css">
        <script type="text/javascript">
            function hot_sale_addcart(id) {
                window.location.href = "hot_sale_addcart.php?id="+id;
            }
    </script>
</head>
<body>
<div class="all">
    <div class="all1">
        <div class="home">
            <div class="header">
                <div class="header1">
                    <div class="name">
                        <a href="index.php"><h1>米尔豪斯</h1></a>
                    </div>
                    <div class="guide">
                        <ul>
                            <li><a href="cart.php">购物车</a></li>
                            <li><a href="../register.html">注&nbsp;册</a></li>
                            <li><a href="../login.html">登&nbsp;陆</a></li>
                            <li><a href="zhongcan_order.php">点&nbsp;餐</a></li>
                            <li><a href="consult.php">留&nbsp;言</a></li>
                            <li><a href="index.php">主&nbsp;页</a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="header2">
                <div class="header3">
                    <h1>Order</h1>
                 </div>
            </div>

            <div class="bottom2">
                <img src="../img/border.png" alt="底线">
            </div>
        </div>

        <div class="middle">
            <div class="middle1">
                <ul>
                    <li><a href="index.php">主页</a></li>
                    <li class="middle3">/</li>
                    <li class="middle2">菜单</li>
                </ul>
            </div>
            <div class="bottom1">
                <img src="../img/border.png" alt="底线">
            </div>
        </div>
    </div>
<?php 
    session_start();
    header("Content-type:text/html;charset=utf-8");
    include "../../lib/DB.php";
    $db = new DB();
    $cid = isset($_GET['cid']) ? $_GET['cid'] : null;
    if(is_null($cid))
    {
        $cid = $db->table('classification')->find();
        $cid = $cid['cid'];
    }
    $cat = $db->table('classification')->select();
    $goods = $db->table('goods')->where(['c_id' => $cid])->select();
    $url = $_SERVER['SERVER_NAME']."/houtai/php/goods/";
 ?>
    <div class="all2">
        <h1>Menu</h1>
        <div class="menu">
            <div class="menu_guide">
                <!--分类-->
                <ul>
                    <?php foreach($cat as $k => $v):?>
                        <li><a href="zhongcan_order.php?cid=<?php echo $v['cid']?>" class="<?php if($cid == $v['cid']){echo 'active';}?>"><img src="../img/中餐.png" >&nbsp;&nbsp;<?php echo $v['cname']?></a></li>
                    <?php endforeach;?>

                </ul>
            </div>
            <div class="order">
                <form action="zhongcan_addcart.php" method="post">



                    <?php foreach ($goods as $k => $items):?>
                        <div class="food">
                            <ul>
                                <li>

                                    <img src="//<?php echo $url.$items['goods_url'] ?>" width="192" height="161">
                                    <div class="card">
                                        <h2><?php echo $items['goods_name']?></h2>
                                        <span><p><?php echo $items['price']?>￥&nbsp;&nbsp;1份</p></span>

                                        <a href="javascript:hot_sale_addcart(<?php echo $items['gid']?>)">加入购物车</a>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    <?php endforeach;?>

            </form>
            </div>         
        </div>
    </div>

    <div class="footer">
        <h1>欢迎来到米尔豪斯酒店订餐</h1>
    </div>

</div>
</body>
</html>